﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script src="../common/common.js"></script>
    <script src="js/BicycleShop.js"></script>
    <script src="js/XHR.js"></script>
    <script src="js/RSSReader.js"></script>
    <script>

        // Bicycle Shop Factory
        var myShop = new SilverBicycleShop();
        var mySpeedster = myShop.sellBicycle("The Speedster");

        // XHR Factory (SimpleHandler)
        var handler = new SimpleHandler();
        handler.request(
            "POST",
            "http://localhost:1446/DesignPattern/webservices/SampleWebService.asmx/GetData",
            {
                success: function (responseText) {
                    var data = JSON.parse((JSON.parse(responseText).d));
                    console.log(data.ID + ":" + data.Data);
                },
                failure: function (status) { console.log(status); }
            },
            JSON.stringify({ postData: "{ 'data': 'SimpleHandler' }" })
        );

        // XHR Factory (QueueHandler)
        var handler2 = new QueueHandler();
        handler2.request(
            "POST",
            "http://localhost:1446/DesignPattern/webservices/SampleWebService.asmx/GetData",
            {
                success: function (responseText) {
                    var data = JSON.parse((JSON.parse(responseText).d));
                    console.log(data.ID + ":" + data.Data);
                },
                failure: function (status) { console.log(status); }
            },
            JSON.stringify({ postData: "{ 'data': 'QueueHandler' }" })
        );

        // XHR Factory (OfflineHandler)
        var handler3 = new OfflineHandler();
        handler3.request(
            "POST",
            "http://localhost:1446/DesignPattern/webservices/SampleWebService.asmx/GetData",
            {
                success: function (responseText) {
                    var data = JSON.parse((JSON.parse(responseText).d));
                    console.log(data.ID + ":" + data.Data);
                },
                failure: function (status) { console.log(status); }
            },
            JSON.stringify({ postData: "{ 'data': 'OfflineHandler' }" })
        );

        // XHR Factory (XhrManager)
        var dynamicHandler = XhrManager.createXhrHandler();
        dynamicHandler.request(
            "POST",
            "http://localhost:1446/DesignPattern/webservices/SampleWebService.asmx/GetData",
            {
                success: function (responseText) {
                    var data = JSON.parse((JSON.parse(responseText).d));
                    console.log(data.ID + ":" + data.Data);
                },
                failure: function (status) { console.log(status); }
            },
            JSON.stringify({ postData: "{ 'data': 'OfflineHandler' }" })
        );

        $(function () { 
            //RSS Reader
            var rssReader = new FeedReader(new ListDisplay('list', document.getElementById('blog')), XhrManager.createXhrHandler(), conf);
        });
    </script>
</head>
<body>
    <div id="blog">

    </div>
</body>
</html>
